package com.bnz.mp.test;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bnz.mp.entity.Student;
import com.bnz.mp.service.IStudentService;

import org.junit.jupiter.api.Test;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.Collections;

/**
 * @author xy
 * @date 2022/10/20
 */

@SpringBootTest
public class Mp {

    private String url ="jdbc:mysql://120.48.117.8:3306/xy?useUnicode=ture&characterEncoding=utf8";
    private String username="root";
    private String password="123456!";
    @Autowired
    IStudentService studentService;

    @Test
    public void m1(){
        System.out.println(studentService.list().toString());

    }
    @Test
    public void page(){
        Page<Student> page = new Page<>(1,3);
        Page<Student> page1 = studentService.page(page);
        QueryWrapper wrapper = new QueryWrapper();
        QueryWrapper wrapper1 = new  ServiceImpl().query().
        wrapper.like("sname","金");
        //wrapper.
        Page page2 = studentService.page(page, wrapper);
       page2.getRecords().forEach(i ->{
           System.out.println(i);
        });
    }
}
